
package org.platform.processor.diagnose.arith;

import org.platform.constant.DiagnoseConst;
import org.platform.processor.diagnose.IArithIllate;

import java.util.Map;
import java.util.Map.Entry;

/**
 * @author sunjian
 * 树节点OR或算法
 */
public class OrArithIllate implements IArithIllate {

    @Override
    public int getIllateResult(Map<Long, Integer> condition) {
        boolean hasUnknown = false;

        for (Entry<Long, Integer> one : condition.entrySet()) {
            if (one.getValue() == DiagnoseConst.DIAGNOSE_ABATE_UNKNOWN) {
                hasUnknown = true;
                continue;
            }

            if (one.getValue() == DiagnoseConst.DIAGNOSE_ABATE) {
                return DiagnoseConst.DIAGNOSE_ABATE;
            }
        }

        if (hasUnknown) {
            return DiagnoseConst.DIAGNOSE_ABATE_UNKNOWN;
        }

        return DiagnoseConst.DIAGNOSE_NOT_ABATE;
    }

}
